package com.relytosoft.mizar.analyze.algorithm.structure.bitmain.service.impl;

import com.alibaba.fastjson.JSON;
import com.relytosoft.dubhe.common.core.utils.BeanCopyUtils;
import com.relytosoft.mizar.analyze.algorithm.base.feign.bitman.StructureFeignService;
import com.relytosoft.mizar.analyze.algorithm.base.service.FeatureService;
import com.relytosoft.mizar.analyze.base.entity.bitman.FeatureExtractionDto;
import com.relytosoft.mizar.analyze.base.entity.pojo.dto.FeatureComparisonReqDto;
import com.relytosoft.mizar.analyze.base.entity.pojo.dto.FeatureExtractionReqDto;
import com.relytosoft.mizar.analyze.base.entity.pojo.request.btdl.common.BtdlDataReq;
import com.relytosoft.mizar.analyze.common.utils.BitmanRequestUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * FeatureServiceImpl
 *
 * @Author SunLi
 * @Date: 2022/5/16 16:56
 * @Version 1.0
 */
@Service
public class FeatureServiceImpl implements FeatureService {

    @Resource
    private StructureFeignService structureFeignService;

    @Override
    public String featureExtraction(FeatureExtractionReqDto featureExtractionReqDto) {
        FeatureExtractionDto featureExtractionDto = BeanCopyUtils.copy(featureExtractionReqDto, FeatureExtractionDto.class);
        featureExtractionDto.setPictureType(2);
        String result = BitmanRequestUtil.handlerResponse(structureFeignService.featureExtraction(JSON.toJSONString(featureExtractionDto)));
        return JSON.toJSONString(JSON.parseObject(result, BtdlDataReq.class));
    }

    @Override
    public Double featureComparison(FeatureComparisonReqDto featureComparisonReqDto) {
        return null;
    }
}
